import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import collapse from './module/collapse'
import user from './module/user'
import permission from './module/permission'
import tagViews from './module/tagViews'
import changeTheme from './module/changeTheme'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    collapse,
    user,
    permission,
    tagViews,
    changeTheme
  },
  getters,
  // plugins: [createPersistedState()]
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      reducer(val) {
        return {
          // 只储存state中的index
          collapse: val.collapse,
          changeTheme: val.changeTheme
        }
      }
    })
  ]
})
